package com.gym.code.config.admin.client;

import java.sql.Connection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.gym.code.config.admin.client.model.DBDatabaseModel;
import com.gym.code.config.admin.client.model.DBTableModel;

/**
 * 
 * @author xinchun.wang
 * @email: 532002108@qq.com
 * @createTime 2015-4-26 下午12:14:26
 */
@Service
public class DBHelpService {
	public List<DBTableModel> getTableInfoList(DBDatabaseModel dbModel) {
		Connection conn = DBUtils.getConnection(dbModel);
		return TableUtils.getTableList(conn);
	}
	
	
	public Map<String,DBTableModel> getTableInfoMap(DBDatabaseModel dbModel) {
		List<DBTableModel> list = getTableInfoList(dbModel);
		
		Map<String,DBTableModel> result = new HashMap<String,DBTableModel>();
		for(DBTableModel item : list){
			result.put(item.getTableName(), item);
		}
		return result;
	}
}
